<html>
<head><meta charset="utf-8"><title>How do I test running cargo as nightly? · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/How.20do.20I.20test.20running.20cargo.20as.20nightly.3F.html">How do I test running cargo as nightly?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226688273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/How%20do%20I%20test%20running%20cargo%20as%20nightly%3F/near/226688273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/How.20do.20I.20test.20running.20cargo.20as.20nightly.3F.html#226688273">(Feb 17 2021 at 16:56)</a>:</h4>
<p>I'm working on <a href="https://github.com/rust-lang/cargo/issues/7088">https://github.com/rust-lang/cargo/issues/7088</a>. I have the following test:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[cargo_test]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">rustc_bootstrap_nightly</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">project</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">file</span><span class="p">(</span><span class="s">"src/main.rs"</span><span class="p">,</span><span class="w"> </span><span class="s">"fn main() {}"</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">file</span><span class="p">(</span><span class="w"></span>
<span class="w">            </span><span class="s">"build.rs"</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">r</span><span class="err">#</span><span class="s">"</span>
<span class="s">            fn main() {</span>
<span class="s">                println!("</span><span class="n">cargo</span>:<span class="nc">rustc</span><span class="o">-</span><span class="n">env</span><span class="o">=</span><span class="n">RUSTC_BOOTSTRAP</span><span class="o">=</span><span class="mi">1</span><span class="s">");</span>
<span class="s">            }</span>
<span class="s">        "</span><span class="err">#</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">build</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">p</span><span class="p">.</span><span class="n">cargo</span><span class="p">(</span><span class="s">"build"</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">masquerade_as_nightly_cargo</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">with_stderr_contains</span><span class="p">(</span><span class="s">"warning: Cannot set `RUSTC_BOOTSTRAP=1` [..]"</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">with_status</span><span class="p">(</span><span class="mi">101</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">run</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>This fails with</p>
<div class="codehilite"><pre><span></span><code>---- build_script_env::rustc_bootstrap_nightly stdout ----
running `/home/joshua/cargo/target/debug/cargo build`
thread &#39;build_script_env::rustc_bootstrap_nightly&#39; panicked at &#39;
Expected: execs
    but: expected to find:
warning: Cannot set `RUSTC_BOOTSTRAP=1` [..]

did not find in output:
   Compiling foo v0.0.1 (/home/joshua/cargo/target/cit/t0/foo)
[src/cargo/core/compiler/custom_build.rs:577] nightly_features_allowed() = false
error: Cannot set `RUSTC_BOOTSTRAP=1` from build script of `foo v0.0.1 (/home/joshua/cargo/target/cit/t0/foo)`.
</code></pre></div>
<p>I don't understand why <code>masquerade_as_nightly_cargo()</code> doesn't tell cargo to allow nightly features. I tried <code>enable_nightly_features()</code> but I think that only works in unit tests since cargo is spawned as a subprocess.</p>



<a name="226688314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/How%20do%20I%20test%20running%20cargo%20as%20nightly%3F/near/226688314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/How.20do.20I.20test.20running.20cargo.20as.20nightly.3F.html#226688314">(Feb 17 2021 at 16:56)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="239881">@Josh Triplett</span></p>



<a name="226689783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/How%20do%20I%20test%20running%20cargo%20as%20nightly%3F/near/226689783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/How.20do.20I.20test.20running.20cargo.20as.20nightly.3F.html#226689783">(Feb 17 2021 at 17:05)</a>:</h4>
<p>I added more debugging and the channel is right, just not whether features are enabled:</p>
<div class="codehilite"><pre><span></span><code>   Compiling foo v0.0.1 (/home/joshua/cargo/target/cit/t1/foo)
[src/cargo/core/features.rs:715] &amp;channel()[..] = &quot;nightly&quot;
[src/cargo/core/compiler/custom_build.rs:577] nightly_features_allowed() = false
error: Cannot set `RUSTC_BOOTSTRAP=1` from build script of `foo v0.0.1 (/home/joshua/cargo/target/cit/t1/foo)`.
</code></pre></div>



<a name="226690730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/How%20do%20I%20test%20running%20cargo%20as%20nightly%3F/near/226690730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/How.20do.20I.20test.20running.20cargo.20as.20nightly.3F.html#226690730">(Feb 17 2021 at 17:10)</a>:</h4>
<p>this fixes it, but I'm not sure what other tests it affects:</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs</span>
<span class="gh">index 494e33993..9a75a7b7e 100644</span>
<span class="gd">--- a/src/cargo/core/features.rs</span>
<span class="gi">+++ b/src/cargo/core/features.rs</span>
<span class="gu">@@ -712,8 +712,8 @@ pub fn nightly_features_allowed() -&gt; bool {</span>
     if ENABLE_NIGHTLY_FEATURES.with(|c| c.get()) {
         return true;
     }
<span class="gd">-    match &amp;channel()[..] {</span>
<span class="gd">-        "nightly" | "dev" =&gt; NIGHTLY_FEATURES_ALLOWED.with(|c| c.get()),</span>
<span class="gi">+    match dbg!(&amp;channel()[..]) {</span>
<span class="gi">+        "nightly" | "dev" =&gt; true, //NIGHTLY_FEATURES_ALLOWED.with(|c| c.get()),</span>
         _ =&gt; false,
     }
 }
</code></pre></div>



<a name="226693481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/How%20do%20I%20test%20running%20cargo%20as%20nightly%3F/near/226693481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/How.20do.20I.20test.20running.20cargo.20as.20nightly.3F.html#226693481">(Feb 17 2021 at 17:29)</a>:</h4>
<p>also, I want to pass the name of the package (without the <code>(/path/to/name)</code> added), but <code>Rc&lt;Package&gt;</code> doesn't implement <code>Sync</code> so I can't pass it to <code>Work::new</code>. Would you prefer I add a new argument to <code>parse</code> or change the Rc to an Arc?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>